package org.jaaksi.kottlindemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf
import extension.addFragment
import extension.argument
import libcore.kotpref.AppSp
import org.jaaksi.kottlindemo.databinding.ActivityTestFlowBinding
import org.jaaksi.kottlindemo.test.TestFragment
import org.jaaksi.kottlindemo.ui.SecondActivity
import org.jetbrains.anko.startActivity

class TestActivity : AppCompatActivity() {
    private val binding by lazy { ActivityTestFlowBinding.inflate(layoutInflater) }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)

//        println(">> age = ${AppSp.age}, name = ${AppSp.name}")
        println(">> age2 = ${AppSp.age}")
        addFragment(
            supportFragmentManager,
            android.R.id.content,
            TestFragment::class.java,
            bundle = bundleOf(
                "ID" to 1
            )
        )

        binding.btn2.setOnClickListener {
            startActivity<SecondActivity>(
                "ID" to 1
            )
        }
    }
}